<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="test"></div>
  
  <!-- 引入react核心库 -->
  <script src="https://unpkg.com/react@16/umd/react.development.js"></script>
  <!-- 用于支持react操作DOM -->
  <script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
  <!-- 用于将jsx转为js -->
  <script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
  
  <script type="text/babel">
    class Login extends React.Component{

      handleSubmit=(event)=>{
        event.preventDefault();//阻止表单默认提交
        const {username,password}=this;
        alert(`你输入的账号是：${username.value}，你输入是密码是：${password.value}`)
      }
      render(){
        return(
          <form action="http://www.baidu.com" onSubmit={this.handleSubmit}>
            账号：<input ref={c=>this.username=c} type="text" name='username'/>  
            密码：<input ref={c=>this.password=c} type="password" name='password'/> 
            <button>登录</button> 
          </form>
        )
      }
    }

    ReactDOM.render(<Login/>,document.getElementById('test'))
  </script>
</body>
</html>